<?php
class Map{
//经纬度转换为百度坐标
	public function getbaidu_ll($long,$lat){
		$ret = $this->call_get("http://api.map.baidu.com/geoconv/v1/?coords={$long},{$lat}&from=1&to5&ak=".BAIDUAK);
		$temp=json_decode($ret,true);
		if(!empty($temp["result"])){
			$new["long"]=$temp["result"][0]["x"];
			$new["lat"]=$temp["result"][0]["y"];
		}else{
			$new["long"]=$long;
			$new["lat"]=$lat;
		}
		return $new;
	}
//百度坐标转回成经纬度
	public function backbaidu_ll($long,$lat){
		$ret = $this->call_get("http://api.map.baidu.com/geoconv/v1/?coords={$long},{$lat}&from=1&to5&ak=".BAIDUAK);
		$temp=json_decode($ret,true);
		$templong=$temp["result"][0]["x"];
		$templat=$temp["result"][0]["y"];
		$new["long"]=($long*2)-$templong;
		$new["lat"]=($lat*2)-$templat;
		return $new;
	}	
}